//
//  JXHCostomProgressView.swift
//  JXHSinaWeiBo
//
//  Created by juxiaohui on 16/11/14.
//  Copyright © 2016年 juxiaohui. All rights reserved.
//

import UIKit

class JXHCostomProgressView: UIView {

    
    var progress : CGFloat = 0 {
        didSet{
            setNeedsDisplay()
        }
    }
    
    override func draw(_ rect: CGRect) {
         super.draw(rect)
     
        let center = CGPoint.init(x: rect.width * 0.5, y: rect.height * 0.5)
        let radius = rect.width * 0.5 - 5
        
        let start = CGFloat (-M_PI_2)
        let end = CGFloat(M_PI * 2) * progress + start
    
        let path =
        UIBezierPath.init(arcCenter: center, radius: radius, startAngle: start, endAngle: end, clockwise: true) //关闭路径
        //绘制到中心点的线
        
        path.addLine(to: center)
        path.close()
        UIColor.init(white: 1.0, alpha: 1.0).withAlphaComponent(0.9).set()
        
        //开始绘制
        path.fill()
        
    }
}
